package com.wc.算法提高课.B第二章_搜索.DFS之搜索顺序.分成互质组;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/9/27 11:56
 * @description https://www.acwing.com/problem/content/1120/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 15;
    static int[] p = new int[N];
    static boolean[] st = new boolean[N];
    static int[][] group = new int[N][N];
    static int n, res = N;

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 0; i < n; i++) p[i] = sc.nextInt();
        dfs(1, 0, 0, 0);
        out.println(res);
        out.flush();
    }

    static void dfs(int g, int gc, int tc, int start) {
        if (g >= res) return;
        if (tc == n) res = g;
        // 检查该组是否有加入, 没有就说明需要新开组
        boolean flg = true;
        for (int i = start; i < n; i++) {
            if (!st[i] && check(group[g], gc,i)) {
                st[i] = true;
                group[g][gc] = i;
                dfs(g, gc + 1, tc + 1, i + 1);
                st[i] = false;
                flg = false;
            }
        }
        if (flg) dfs(g + 1, 0, tc, 0);
    }

    static boolean check(int[] group, int gc, int i) {
        for (int j = 0; j < gc; j++) {
            if (gcd(p[group[j]], p[i]) > 1) return false;
        }
        return true;
    }

    static int gcd(int a, int b) {
        return b > 0 ? gcd(b, a % b) : a;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
